"use strict"

/**
 * 乌鲁木齐市市政府采购网爬虫
 *  
 */

var Base = require("./base");
var mq_spider = new Base();
mq_spider.name = "乌鲁木齐市采购网";
mq_spider.encode = "GBK";
mq_spider.contentType = "text";

mq_spider.getPageUrl = function (pg) {
    return "http://www.wlmqcg.com.cn/Project/Bulletin_Query.jsp?offset=" + (pg - 1) + "&bulletin_name=&year1=&month1=&day1=&year2=&month2=&day2=&category_id=&project_id=&bulletin_id=&type=&flag=";
};

mq_spider.getItems = function (data) {
    var items = []
    var reg = new RegExp("<a href=\"(.*?)\"[\\s\\S]+?>(.*?)<\/a>", "ig");
    var regv;
    while (regv = reg.exec(data)) {
        var id = regv[1];
        var title = regv[2];
        var item = {};
        item.title = title;
        item.url = "http://www.wlmqcg.com.cn" + id.substring(2);
        item.source = mq_spider.name;
        items.push(item);
    }
    return items;
};


exports = module.exports = mq_spider;